Testing Backbone.js by Roemer Ryan
Author:Roemer, Ryan
Language: eng
Format: epub
Publisher: Packt Publishing
Anonymous spies
Spies can be created as anonymous standalone functions, which are often used to test event logic in Backbone.js applications. For example, we create a Backbone.js event object and an anonymous Sinon.JS spy in the following code. The spy listens to the foo event, which we trigger. Then, we can inspect the spy and assert that the spy was called once and passed 42 as a parameter:
it("calls anonymous spy on event", function () { var eventer = _.extend({}, Backbone.Events), spy = sinon.spy(); // Set up the spy. eventer.on("foo", spy); expect(spy.called).to.be.false; // Fire event. eventer.trigger("foo", 42); // Check number of calls. expect(spy.calledOnce).to.be.true; expect(spy.callCount).to.equal(1); // Check calling arguments. expect(spy.firstCall.args[0]).to.equal(42); expect(spy.calledWith(42)).to.be.true; });
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7811)
Grails in Action by Glen Smith Peter Ledbrook(7722)
Azure Containers Explained by Wesley Haakman & Richard Hooper(6874)
Configuring Windows Server Hybrid Advanced Services Exam Ref AZ-801 by Chris Gill(6870)
Running Windows Containers on AWS by Marcio Morales(6401)
Kotlin in Action by Dmitry Jemerov(5092)
Microsoft 365 Identity and Services Exam Guide MS-100 by Aaron Guilmette(5088)
Combating Crime on the Dark Web by Nearchos Nearchou(4663)
Microsoft Cybersecurity Architect Exam Ref SC-100 by Dwayne Natwick(4653)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4438)
The Ruby Workshop by Akshat Paul Peter Philips Dániel Szabó and Cheyne Wallace(4354)
The Age of Surveillance Capitalism by Shoshana Zuboff(3989)
Python for Security and Networking - Third Edition by José Manuel Ortega(3906)
The Ultimate Docker Container Book by Schenker Gabriel N.;(3572)
Learn Wireshark by Lisa Bock(3565)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3530)
Mastering Python for Networking and Security by José Manuel Ortega(3378)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3359)
Blockchain Basics by Daniel Drescher(3330)
